package yjpay.api.web.control;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import yjpay.service.PayAPIService;

/**
 * 调用检查银行卡接口示例
 * 
 * @author junqinghuang
 * @date 2013-8-14
 */
@Controller
public class BankCardCheckWebCtrl {

	@Resource(name = "payAPIService")
	private PayAPIService payAPIService;

	@RequestMapping(value = "/pay/to_bankcardcheck")
	public ModelAndView home(HttpServletRequest request) {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("pay/bankcardcheck.jsp");
		return modelAndView;
	}

	@RequestMapping(value = "/pay/bankcardcheck")
	public ModelAndView biandpay(Model model,
			@RequestParam("cardno") String cardno, HttpServletRequest request)
			throws Exception {

		String payresult = payAPIService.bankCardCheck(cardno);

		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("pay/pay_result.jsp");
		modelAndView.addObject("apiname", "检查银行卡接口");
		modelAndView.addObject("payresult_view", payresult);

		return modelAndView;
	}

}
